package com.industrial.loweff.service.impl;

import cn.hutool.core.util.IdUtil;
import com.industrial.common.core.utils.DateUtils;
import com.industrial.common.core.utils.StringUtils;
import com.industrial.common.security.utils.SecurityUtils;
import com.industrial.loweff.domain.CityLevelCdCount;
import com.industrial.loweff.domain.JcQueryParam;
import com.industrial.loweff.domain.LowEfficiencyBenefitEvaluation;
import com.industrial.loweff.domain.SysEnterDiagnosisInfo;
import com.industrial.loweff.domain.vo.IndexResVo;
import com.industrial.loweff.mapper.EnterpriseDiagnosisMapper;
import com.industrial.loweff.service.IEnterpriseDiagnosisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EnterpriseDiagnosisServiceImpl implements IEnterpriseDiagnosisService {

    @Autowired
    private EnterpriseDiagnosisMapper enterpriseDiagnosisMapper;

    @Autowired
    private StringRedisTemplate redisTemplate;

    /**
     * @param jcQueryParam
     */
    @Override
    public List<LowEfficiencyBenefitEvaluation> list(JcQueryParam jcQueryParam) {
        List<LowEfficiencyBenefitEvaluation> result = enterpriseDiagnosisMapper.list(jcQueryParam);
        for(LowEfficiencyBenefitEvaluation temp : result){
            temp.setCounty(redisTemplate.opsForValue().get("area:" + temp.getCounty()));
            temp.setCity(redisTemplate.opsForValue().get("area:" + temp.getCity()));
            temp.setProvince(redisTemplate.opsForValue().get("area:" + temp.getProvince()));
        }
        return result;
    }

    /**
     * <p>
     * 查询企业指标值
     * </p>
     *
     * @param companyId
     * @return
     */
    @Override
    public List<Map<String,String>> queryIndexData(JcQueryParam jcQueryParam) {
        JcQueryParam queryParam = new JcQueryParam();
        //查询全省指标平均值
        queryParam.setProvince("370000");
        queryParam.setYears(jcQueryParam.getYears());
        IndexResVo provinceMap = enterpriseDiagnosisMapper.queryIndexAvgValue(queryParam);
        //查询市级指标平均值
        Map<String,String> cityCountyCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());
        String cityCode = "";
        String countyCode = "";
        if(StringUtils.isBlank(cityCode = cityCountyCode.get("city"))
                || StringUtils.isBlank(countyCode = cityCountyCode.get("county"))){
            throw new RuntimeException("没有找到企业的城市或县区的代码");
        }
        queryParam.setCity(cityCode);
        IndexResVo cityMap = enterpriseDiagnosisMapper.queryIndexAvgValue(queryParam);
        queryParam.setCounty(countyCode);
        IndexResVo countyMap = enterpriseDiagnosisMapper.queryIndexAvgValue(queryParam);

        //查询企业的指标值
        LowEfficiencyBenefitEvaluation companyIndexValue = enterpriseDiagnosisMapper.queryCompanyIndexValue(jcQueryParam.getCompanyId(),jcQueryParam.getYears());

        List<Map<String,String>> list = new ArrayList<>();

        Map<String,String> ydssMap = new HashMap<>(16);
        ydssMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore1() == null ? "0" : companyIndexValue.getScore1().toString());
        ydssMap.put("province",provinceMap == null ? "0" : provinceMap.getDwydss());
        ydssMap.put("title","单位用地税收");
        ydssMap.put("city",cityMap == null ? "0" : cityMap.getDwydss());
        ydssMap.put("county",countyMap == null ? "0" : countyMap.getDwydss());
        list.add(ydssMap);

        Map<String,String> nhssMap = new HashMap<>(16);
        nhssMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore2() == null ? "0" : companyIndexValue.getScore2().toString());
        nhssMap.put("province",provinceMap == null ? "0" : provinceMap.getDwnhss());
        nhssMap.put("city",cityMap == null ? "0" : cityMap.getDwnhss());
        nhssMap.put("title","单位能耗税收");
        nhssMap.put("county",countyMap == null ? "0" : countyMap.getDwnhss());
        list.add(nhssMap);

        Map<String,String> wrwMap = new HashMap<>(16);
        wrwMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore3() == null ? "0" : companyIndexValue.getScore3().toString());
        wrwMap.put("province",provinceMap == null ? "0" : provinceMap.getDwwrw());
        wrwMap.put("city",cityMap == null ? "0" : cityMap.getDwwrw());
        wrwMap.put("title","单位污染物");
        wrwMap.put("county",countyMap == null ? "0" : countyMap.getDwwrw());
        list.add(wrwMap);

        Map<String,String> yfjfMap = new HashMap<>(16);
        yfjfMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore4() == null ? "0" : companyIndexValue.getScore4().toString());
        yfjfMap.put("province",provinceMap == null ? "0" : provinceMap.getYfjf());
        yfjfMap.put("city",cityMap == null ? "0" : cityMap.getYfjf());
        yfjfMap.put("title","研发经费");
        yfjfMap.put("county",countyMap == null ? "0" : countyMap.getYfjf());
        list.add(yfjfMap);

        Map<String,String> qyldMap = new HashMap<>(16);
        qyldMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore5() == null ? "0" : companyIndexValue.getScore5().toString());
        qyldMap.put("province",provinceMap == null ? "0" : provinceMap.getQyld());
        qyldMap.put("city",cityMap == null ? "0" : cityMap.getQyld());
        qyldMap.put("title","全员劳动力");
        qyldMap.put("county",countyMap == null ? "0" : countyMap.getQyld());
        list.add(qyldMap);

        Map<String,String> ydxsMap = new HashMap<>(16);
        ydxsMap.put("company",companyIndexValue == null ? "0" : companyIndexValue.getScore7() == null ? "0" : companyIndexValue.getScore7().toString());
        ydxsMap.put("province",provinceMap == null ? "0" : provinceMap.getYdxs());
        ydxsMap.put("city",cityMap == null ? "0" : cityMap.getYdxs());
        ydxsMap.put("title","单位用地销售");
        ydxsMap.put("county",countyMap == null ? "0" : countyMap.getYdxs());
        list.add(ydxsMap);

        return list;
    }

    /**
     * <p>
     *     查询近5年的用地税收
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String,Object> ydssQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);

        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydssQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score1 = c.getScore1();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score1);
                }
            }

            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setYears(jcQueryParam.getYears());
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdssAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score1 = c.getDwydss();
                String years = c.getYears();
                xAvgAxis.add(years);
                yAvgAxis.add(score1);
            }
            //补齐数组
            if(!xAxis.isEmpty()){
                for(int i = 0 ;i < xAvgAxis.size();i++){
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if(!StringUtils.equals(xAvg,x)){
                        xAxis.add(i,xAvg);
                        yAxis.add(i,"0");
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydssQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score1 = c.getScore1();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score1);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince(companyAreaCode.get("province"));
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdssAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwydss();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }

                //补齐数组
                if(!xAxis.isEmpty()) {
                    for(int i = 0 ;i < xAvgAxis.size();i++){
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if(!StringUtils.equals(xAvg,x)){
                            xAxis.add(i,xAvg);
                            yAxis.add(i,"0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydssQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score1 = c.getScore1();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score1);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince(companyAreaCode.get("province"));
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdssAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwydss();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){
            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());
            jcQueryParam.setUscc(uscc);
            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydssQsHyCharts(jcQueryParam);
            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score1 = temp.getScore1();
                xAxis.add(hy);
                yAxis.add(score1);
            }

            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyYdssAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score = c.getDwydss();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score == null ? "0" : score);
            }
            //补齐数组
            if(!xAxis.isEmpty()) {
                for (int i = 0; i < xAvgAxis.size(); i++) {
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if (!StringUtils.equals(xAvg, x)) {
                        xAxis.add(i, xAvg);
                        yAxis.add(i, "0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * <p>
     * 近5年单位用地销售收入趋势分析
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String, Object> ydxsQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);
        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));

                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score7 = c.getScore7();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score7);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdxsAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYdxs();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1 == null ? "0" : score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for(int i = 0 ;i < xAvgAxis.size();i++){
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if(!StringUtils.equals(xAvg,x)){
                            xAxis.add(i,xAvg);
                            yAxis.add(i,"0");
                        }
                    }
                }

            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score7 = c.getScore7();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score7);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdxsAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYdxs();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));

                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score7 = c.getScore7();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score7);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYdxsAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYdxs();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){

            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());


            jcQueryParam.setUscc(uscc);
            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.ydxsQsHyCharts(jcQueryParam);
            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score7 = temp.getScore7();
                xAxis.add(hy);
                yAxis.add(score7);
            }

            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyYdxsAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score1 = c.getYdxs();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score1 == null ? "0" : score1);
            }

            //补齐数组
            if(!xAxis.isEmpty()) {
                for (int i = 0; i < xAvgAxis.size(); i++) {
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if (!StringUtils.equals(xAvg, x)) {
                        xAxis.add(i, xAvg);
                        yAxis.add(i, "0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * <p>
     * 近5年单位能耗销售收入趋势分析
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String, Object> nhxsQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);
        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.nhxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score2 = c.getScore2();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score2);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwnhAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwnhss();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
                jcQueryParam.setUscc(uscc);


                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.nhxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score2 = c.getScore2();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score2);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwnhAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwnhss();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));

                jcQueryParam.setUscc(uscc);


                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.nhxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score2 = c.getScore2();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score2);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwnhAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwnhss();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){
            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());
            jcQueryParam.setUscc(uscc);

            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.nhxsHyCharts(jcQueryParam);
            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score2 = temp.getScore2();
                xAxis.add(hy);
                yAxis.add(score2);
            }
            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyNhXsAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score = c.getDwnhss();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score == null ? "0" : score);
            }
            //补齐数组
            if(!xAxis.isEmpty()) {
                for(int i = 0 ;i < xAvgAxis.size();i++){
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if(!StringUtils.equals(xAvg,x)){
                        xAxis.add(i,xAvg);
                        yAxis.add(i,"0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * <p>
     * 近5年单位排放销售收入趋势分析
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String, Object> pfxsQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);
        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.pfxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score3 = c.getScore3();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score3);
                }


                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwrwAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwwrw();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));

                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.pfxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score3 = c.getScore3();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score3);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwrwAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwwrw();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.pfxsQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score3 = c.getScore3();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score3);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceDwrwAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getDwwrw();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){
            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());
            jcQueryParam.setUscc(uscc);
            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.dwwrwQsHyCharts(jcQueryParam);
            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score3= temp.getScore3();
                xAxis.add(hy);
                yAxis.add(score3);
            }

            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyDwWrwAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score = c.getDwwrw();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score == null ? "0" : score);
            }
            //补齐数组
            if(!xAxis.isEmpty()) {
                for (int i = 0; i < xAvgAxis.size(); i++) {
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if (!StringUtils.equals(xAvg, x)) {
                        xAxis.add(i, xAvg);
                        yAxis.add(i, "0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * <p>
     * 近5年研发投入强度趋势分析
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String, Object> yftrQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);
        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.yftrQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score4 = c.getScore4();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score4);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYftrAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYfjf();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
                jcQueryParam.setUscc(uscc);

                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.yftrQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score4 = c.getScore4();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score4);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYftrAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYfjf();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.yftrQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score4 = c.getScore4();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score4);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceYftrAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getYfjf();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){

            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());
            jcQueryParam.setUscc(uscc);
            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.yftrQsHyCharts(jcQueryParam);
            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score4= temp.getScore4();
                xAxis.add(hy);
                yAxis.add(score4);
            }
            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyYfjfAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score = c.getYfjf();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score == null ? "0" : score);
            }
            //补齐数组
            if(!xAxis.isEmpty()) {
                for (int i = 0; i < xAvgAxis.size(); i++) {
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if (!StringUtils.equals(xAvg, x)) {
                        xAxis.add(i, xAvg);
                        yAxis.add(i, "0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * <p>
     * 近5年全员劳动生产率趋势分析
     * </p>
     *
     * @param jcQueryParam
     */
    @Override
    public Map<String, Object> qyldQsCharts(JcQueryParam jcQueryParam) {
        Map<String, String> companyAreaCode = enterpriseDiagnosisMapper.queryCompanyCity(jcQueryParam.getCompanyId());

        //查询企业的统一社会信用代码
        String uscc = enterpriseDiagnosisMapper.selectCompanyUssByCompanyId(jcQueryParam.getCompanyId());

        List<String> xAxis = new ArrayList<>(6);
        List<String> yAxis = new ArrayList<>(6);
        List<String> xAvgAxis = new ArrayList<>(6);
        List<String> yAvgAxis = new ArrayList<>(6);
        Map<String,Object> result = new HashMap<>(16);
        if(StringUtils.equals(jcQueryParam.getSelectType(),"province")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.qyldQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score5 = c.getScore5();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score5);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceQylgAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getQyld();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"city")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province")) && StringUtils.isNotBlank(companyAreaCode.get("city"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.qyldQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score5 = c.getScore5();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score5);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceQylgAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getQyld();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"county")){
            if(StringUtils.isNotBlank(companyAreaCode.get("province"))
                    && StringUtils.isNotBlank(companyAreaCode.get("city"))
                    && StringUtils.isNotBlank(companyAreaCode.get("county"))){
//                jcQueryParam.setProvince(companyAreaCode.get("province"));
//                jcQueryParam.setCity(companyAreaCode.get("city"));
//                jcQueryParam.setCounty(companyAreaCode.get("county"));
                jcQueryParam.setUscc(uscc);
                List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.qyldQsCharts(jcQueryParam);
                for(CityLevelCdCount c : cityLevelCdCounts){
                    String score5 = c.getScore5();
                    String years = c.getYears();
                    xAxis.add(years);
                    yAxis.add(score5);
                }

                JcQueryParam queryParam = new JcQueryParam();
                //查询全省指标平均值
                queryParam.setProvince("370000");
                queryParam.setCity(companyAreaCode.get("city"));
                queryParam.setCounty(companyAreaCode.get("county"));
                queryParam.setYears(jcQueryParam.getYears());
                List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexProvinceQylgAvgValue(queryParam);
                for(IndexResVo c : provinceMap){
                    String score1 = c.getQyld();
                    String years = c.getYears();
                    xAvgAxis.add(years);
                    yAvgAxis.add(score1);
                }
                //补齐数组
                if(!xAxis.isEmpty()) {
                    for (int i = 0; i < xAvgAxis.size(); i++) {
                        String xAvg = xAvgAxis.get(i);
                        String x = xAxis.get(i);
                        if (!StringUtils.equals(xAvg, x)) {
                            xAxis.add(i, xAvg);
                            yAxis.add(i, "0");
                        }
                    }
                }
            }
        }else if(StringUtils.equals(jcQueryParam.getSelectType(),"hy")){

            //查询企业的行业
            String industryType = enterpriseDiagnosisMapper.selectCompanyIndustryTypeByCompanyId(jcQueryParam.getCompanyId());
            jcQueryParam.setUscc(uscc);
            List<CityLevelCdCount> cityLevelCdCounts = enterpriseDiagnosisMapper.qyldQsHyCharts(jcQueryParam);

            for(CityLevelCdCount temp : cityLevelCdCounts){
                String hy = temp.getHy();
                String score5= temp.getScore5();
                xAxis.add(hy);
                yAxis.add(score5);
            }
            JcQueryParam queryParam = new JcQueryParam();
            //查询全省指标平均值
            queryParam.setProvince("370000");
            queryParam.setCity(companyAreaCode.get("city"));
            queryParam.setCounty(companyAreaCode.get("county"));
            queryParam.setYears(jcQueryParam.getYears());
            queryParam.setIndustryType(industryType);
            List<IndexResVo> provinceMap = enterpriseDiagnosisMapper.queryIndexHyQyldAvgValue(queryParam);
            for(IndexResVo c : provinceMap){
                String score1 = c.getQyld();
                String hy = c.getHy();
                xAvgAxis.add(hy);
                yAvgAxis.add(score1 == null ? "0" : score1);
            }

            //补齐数组
            if(!xAxis.isEmpty()) {
                for (int i = 0; i < xAvgAxis.size(); i++) {
                    String xAvg = xAvgAxis.get(i);
                    String x = xAxis.get(i);
                    if (!StringUtils.equals(xAvg, x)) {
                        xAxis.add(i, xAvg);
                        yAxis.add(i, "0");
                    }
                }
            }
        }
        result.put("x",xAxis);
        result.put("y",yAxis);
        result.put("xAvgAxis",xAvgAxis);
        result.put("yAvgAxis",yAvgAxis);
        return result;
    }

    /**
     * 发送报告给企业
     *
     * @param params
     * @return
     */
    @Override
    public void sendReport(SysEnterDiagnosisInfo params) {
        if(StringUtils.isBlank(params.getPkId())){
            throw new RuntimeException("请传入PkId");
        }

        String pkIdJoin = params.getPkId();
        String[] pkIdArgs = pkIdJoin.split(",");
        List<SysEnterDiagnosisInfo> list = new ArrayList<>();
        for(String pkId : pkIdArgs){
            SysEnterDiagnosisInfo insetParams = new SysEnterDiagnosisInfo();
            insetParams.setPkId(pkId);
            insetParams.setSendSugges(params.getSendSugges());
            insetParams.setDeveGoals(params.getDeveGoals());
            insetParams.setDeveMeasures(params.getDeveMeasures());
            insetParams.setBaseId(IdUtil.simpleUUID());
            insetParams.setBaseCreateTime(DateUtils.getNowDate());
            insetParams.setBaseCreateBy(SecurityUtils.getUserId());
            list.add(insetParams);
        }
        if(!list.isEmpty()){
            enterpriseDiagnosisMapper.batchInsertSysEnterDiagnosisInfo(list);
        }
    }

    /**
     * @param jcQueryParam
     */
    @Override
    public SysEnterDiagnosisInfo queryJy(JcQueryParam jcQueryParam) {
        SysEnterDiagnosisInfo sysEnterDiagnosisInfo = enterpriseDiagnosisMapper.queryJy(jcQueryParam);
        return sysEnterDiagnosisInfo;
    }
}
